<?php

namespace app\controller;

use think\Controller;
use think\Request;

class Index extends Controller
{
    public function index( $data = '123' )
    {
        return view();
    }

    public function gethomeart()
    {
        $re = db( 'article' )
            ->where( [ 'status' => 1, 'md' => [ 'LT', date( 'Y-m-d H:i:s' ) ] ] )
            ->order( 'like_num desc' )
            ->field( 'id,title,content' )
            ->limit( 2 )->select();

        if ( $re ) {
            $info = [];
            foreach ( $re as $v ) {
                $info[] = [
                    'title' => $v[ 'title' ],
                    'content' => msubstr( getArtListContet( $v[ 'content' ] ), 0, 10, "utf-8" ),
                    'url'=>url('/article/read').'?id='.$v['id']
                ];
            }
            $return = [ 'status' => true, 'info' => $info ];
        } else {
            $return = [ 'status' => false ];
        }
        return json($return);
    }
}